//
//  main.cpp
//  EMT_C
//
//  Created by Duong Ngo on 8/2/17.
//  Copyright © 2016 Duong Ngo. All rights reserved.
//

#include "global.hpp"
#include "steady.hpp"
#include "foc_problem.hpp"
#include "read_file.hpp"

#include <fstream>


int main()
{
    /*------------------------------------------------------------------------------------
     Initial gues
     ----------------------------------------------------------------------------------- */
    
    std::vector<double> ss(var_foc);
    read_from_file(ss);
    
    std::vector<double> x_init(var_foc);
    for (int i=0; i<var_foc; ++i){
        x_init[i]= ss[i];
    }
    
    /*------------------------------------------------------------------------------------
     Solve the steady state
     ----------------------------------------------------------------------------------- */
    
    bool success=true;
    foc_solve(x_init, success);

    
    /*------------------------------------------------------------------------------------
     Write to a file
     ----------------------------------------------------------------------------------- */
    std::ofstream file;
    file.open("//Users//duongngo//Documents//Research//E-Monetary Theory//Paper_and_code//EMT_V6//C code//Output//EMT_steady.txt");
    
    file << result.size() << std::endl;
    for (int i=0; i<var_foc; ++i){
        file << i << " " << std::setprecision(25)<< result[i] << std::endl;
    }
    printf("result[20]=%.25f\n",result[20]);


    
    file.close();
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
    
    
}
